import React, { Component } from 'react';
import './own.less'
import TopNav from '../top_nav'
import BottomBar from '../bottom_bar'
import OwnBanner from './own_banner'
import OwnTabs from './own_tabs'
import { getMemberInfo } from '../../utils/auth'
import parseUrl from '../../utils/parseUrl'
import memberApi from '../../api/member'

class Own extends Component {

  state={
    member:{}
  }
  componentDidMount(){
    window.scrollTo(0,0)
    this.getMember()
  }
  getMember = ()=>{
    let memberId = getMemberInfo().id
    memberApi.info(memberId).then(res=>{
      if(res.success){
        this.setState({
          member:res.data.data
        })
      }
    }).catch(err=>{
      console.log(err);
    })
  }
  render() {
    const {active} = parseUrl(this.props.location.search)
    const {member} = this.state
    return (
      <div className="own-container">
        <TopNav style={{ background: '#fff', color: '#666' }} active="/home" />
        <div className="content">
          <OwnBanner memberInfo = {member}/>
          <OwnTabs active={active}  memberInfo= {member}/>
        </div>
        <BottomBar style={{ background: '#f9f9f9', borderTop: '1px solid #e5e5e5' }} />
      </div>
    );
  }
}

export default Own;